<?php
/**
 * ExceptionCode.php
 * @copyright (c) 2011-2020, Hangzhou DOJI Tech Co., Ltd.
 * This is NOT a freeware, use is subject to license terms.
 * @package ExceptionCode.php
 * @link https://www.tingjunapp.com/
 * @author wujun@lanqb.cn
 * @: ExceptionCode.php 310000 2020-11-11 22:59:25 $
 * */

namespace App\Consts;

class ExceptionCode
{

    // 异常捕获码
    const HANDLER_DEBUG = 100100;
    const HANDLER_INFO = 100200;
    const HANDLER_NOTICE = 100300;
    const HANDLER_WARNING = 100400;
    const HANDLER_ERROR = 100500;
    const HANDLER_SQL = 100600;
    const HANDLER_CRITICAL = 100700;
    const HANDLER_ALTER = 100800;
    const HANDLER_EMERGENCY = 100900;
    const HANDLER_PARSE = 101000;
    const HANDLER_FATAL = 101100;
    // 错误处理级别
    const HANDLER_LEVELS = [
        self::HANDLER_DEBUG => ['level' => 'debug', 'desc' => 'Debug'],
        self::HANDLER_INFO => ['level' => 'info', 'desc' => 'Info'],
        self::HANDLER_NOTICE => ['level' => 'notice', 'desc' => 'Notice'],
        self::HANDLER_WARNING => ['level' => 'warning', 'desc' => 'Warning'],
        self::HANDLER_ERROR => ['level' => 'error', 'desc' => 'HTTP Error'],
        self::HANDLER_SQL => ['level' => 'sql', 'desc' => 'SQL Error'],
        self::HANDLER_CRITICAL => ['level' => 'critical', 'desc' => 'Reflection Error'],
        self::HANDLER_ALTER => ['level' => 'alert', 'desc' => 'Server Timeout'],
        self::HANDLER_EMERGENCY => ['level' => 'emergency', 'desc' => 'Server Exception'],
        self::HANDLER_PARSE => ['level' => 'parse ', 'desc' => 'Parse Error'],
        self::HANDLER_FATAL => ['level' => 'fatal ', 'desc' => 'Fatal Error'],
    ];

    // 公用
    public const OPERATING_SUCCESS = 200;
    public const INSUFFICIENT_PERMISSIONS = 401;
    public const CODE_FAIL = 500;

    public const FILE_UPLOAD_FAILED = 996; // 文件上传失败
    public const ILLEGAL_PARAMETER = 999; // 参数不合法

    // 用户
    public const PASSWORD_ERROR = 1002; // 密码错误

    // 登录
    public const NOT_SET_PASSWORD = 2018; // 未设置密码
    public const LOGIN_FAIL = 2019; // 登录态失效

    public static $msgMap = [
        self::OPERATING_SUCCESS => '操作成功',
        self::INSUFFICIENT_PERMISSIONS => '权限不足',
        self::CODE_FAIL => '服务器内部错误',

        self::FILE_UPLOAD_FAILED => '文件上传失败',
        self::ILLEGAL_PARAMETER => '参数不合法',

        self::PASSWORD_ERROR => '密码错误',

        self::NOT_SET_PASSWORD => '未设置密码',
        self::LOGIN_FAIL => '身份认证失败，请重新登录',
    ];

}
